<?php 
    //检测手机号是否被注册过  注册过返回0 没有返回1 
    header("content-type:text/html;charset=utf-8");
    $tel = $_GET['tel'];
    $pdo = new PDO('mysql:host=123.57.16.97;dbname=device_binding','root','zqVnUy6cxsQXbpEZ');
    $pdo->exec('set names utf8');
    $sql = "SELECT * from user WHERE tel = $tel";
    $res = $pdo->query($sql)->fetch(PDO::FETCH_ASSOC);
    $old_res = check_old_tel($tel);
    if($res || $old_res){
        echo 0;
    }else{
        echo 1;
    }

    function check_old_tel($tel){
        $pdo_user_old = new PDO('mysql:host=123.57.16.97;dbname=ucenter','root','zqVnUy6cxsQXbpEZ');
        $pdo_user_old->exec('set names utf8');
        $old_sql = "SELECT * FROM uc_members WHERE username = ".$tel;
        $old_login_data = $pdo_user_old->query($old_sql)->fetch(PDO::FETCH_ASSOC);
        return $old_login_data;
    }
 ?>